<template>
  <div id="app">
    <div class="item-header">
      <div class="detail-header">
        <div class="detail-header-subtitle">线索</div>
        <div class="detail-header-body">
          <div class="detail-header-left">
            <span class="detail-header-title">{{ data.leadsName }}</span>
            <el-icon class="focus-icon"><Star /></el-icon>
          </div>
          <div class="detail-header-right">
            <el-button @click="openUpdataDialog" color="#0052CC" :icon="Edit">
              编辑
            </el-button>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="转移"
              placement="top"
            >
              <el-button
                @click="transferOwnerUser"
                :icon="transmuteIcon"
                class="drawer-btn"
              />
            </el-tooltip>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="转化"
              placement="top"
            >
              <el-button
                :icon="customerTransformationIcon"
                class="drawer-btn"
              />
            </el-tooltip>
            <el-tooltip
              class="box-item"
              effect="dark"
              content="删除"
              placement="top"
            >
              <el-button
                @click="deleteData"
                :icon="deleteIcon"
                class="drawer-btn"
              />
            </el-tooltip>
          </div>
        </div>
        <div class="detail-base">
          <div class="base-item">
            <div class="base-title">线索来源：</div>
            <div class="base-value text-one-line">
              {{ handleLeadsSource() }}
            </div>
          </div>
          <div class="base-item">
            <div class="base-title">手机：</div>
            <div class="base-value text-one-line">
              {{ data.phone }}
            </div>
          </div>
          <div class="base-item">
            <div class="base-title">负责人：</div>
            <div class="base-value text-one-line">
              {{ data.ownerUserName }}
            </div>
          </div>
          <div class="base-item">
            <div class="base-title">创建时间：</div>
            <div class="base-value text-one-line">
              {{ data.createTime }}
            </div>
          </div>
        </div>
        <div class="create-bar"></div>
        <div class="tags-content">
          <div class="tag-view">
            <span class="tag-referene">
              <el-icon><tagsIcon /></el-icon>
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { Star, Edit } from '@element-plus/icons-vue'
import transmuteIcon from '@/assets/font/transmuteIcon.vue'
import customerTransformationIcon from '@/assets/font/customerTransformationIcon.vue'
import deleteIcon from '@/assets/font/deleteIcon.vue'
import tagsIcon from '@/assets/font/tagsIcon.vue'

const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
  openUpdataDialog: {
    type: Function,
    required: true,
  },
  deleteData: {
    type: Function,
    required: true,
  },
  transferOwnerUser: {
    type: Function,
    required: true,
  },
})

function handleLeadsSource() {
  let leadsSource = props.data.leadsSource
  if (leadsSource == 1) {
    return '促销'
  } else if (leadsSource == 2) {
    return '搜索引擎'
  } else if (leadsSource == 3) {
    return '广告'
  } else {
    return '转介绍'
  }
}
</script>
<style scoped>
.item-header {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px #172b4d1a;
  margin: 16px 8px 0;
  overflow: hidden;
  padding: 16px;
}

.detail-header {
  padding: 0;
}

.detail-body {
  display: flex;
}

.detail-header-subtitle {
  color: #6b778c;
  font-size: 14px;
  margin-bottom: 2px;
}

.detail-header-body {
  align-items: center;
  display: flex;
  justify-content: space-between;
  text-align: left;
  width: 100%;
  flex-direction: row;
}

.detail-header-left,
.detail-header-right {
  align-items: center;
  display: flex;
}

.drawer-btn {
  width: 32px;
  height: 30px;
}

.detail-header-title {
  display: flex;
  font-size: 24px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.focus-icon {
  color: #dfe1e6;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  margin-left: 16px;
}

.detail-base {
  margin: 12px 0 0;
  width: auto;
  position: relative;
}

.base-item {
  align-items: center;
  display: flex;
  min-height: 24px;
  overflow: hidden;
}

.base-title {
  color: #6b778c;
  margin-right: 8px;
  font-size: 14px;
}

.text-one-line {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tags-content {
  margin-top: 8px;
}

.tag-view {
  display: flex;
  flex-wrap: wrap;
}

.tag-referene {
  border: none;
  width: 14px;
  height: 14px;
  padding: 2px;
}

.create-bar {
  margin-left: 0;
  margin-right: 0;
  margin-top: 16px;
}
</style>
